package com.ktgj.customer.controller;

import java.text.ParseException;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.customer.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CustomerRightdetail;
import com.ktgj.customer.service.ICustomerRightdetailService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 会员权益Controller
 * 
 * @author ruoyi
 * @date 2021-07-30
 */
@ControllerAdvice
@RestController
@RequestMapping("/customerRightdetail")
public class CustomerRightdetailController extends BaseController
{
    @Autowired
    private ICustomerRightdetailService customerRightdetailService;

    /**
     * 查询会员权益列表
     */
    @PreAuthorize(hasPermi = "customer:customerRightdetail:list")
    @GetMapping("/list")
    public TableDataInfo list(CustomerRightdetail customerRightdetail)
    {
        startPage();
        List<CustomerRightdetail> list = customerRightdetailService.selectCustomerRightdetailList(customerRightdetail);
        return getDataTable(list);
    }

    /**
     * 导出会员权益列表
     */
    @PreAuthorize(hasPermi = "customer:customerRightdetail:export")
    @Log(title = "会员权益", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerRightdetail customerRightdetail) throws IOException
    {
        List<CustomerRightdetail> list = customerRightdetailService.selectCustomerRightdetailList(customerRightdetail);
        ExcelUtil<CustomerRightdetail> util = new ExcelUtil<CustomerRightdetail>(CustomerRightdetail.class);
        util.exportExcel(response, list, "会员权益数据");
    }

    /**
     * 获取会员权益详细信息
     */
    //@PreAuthorize(hasPermi = "customer:customerRightdetail:query")
    @GetMapping(value = "/{icustomerRightdetailD}")
    public AjaxResult getInfo(@PathVariable("icustomerRightdetailD") Long icustomerRightdetailD){
        return AjaxResult.success(customerRightdetailService.selectCustomerRightdetailById(icustomerRightdetailD));
    }

    /**
     * 新增会员权益
     */
    //@PreAuthorize(hasPermi = "customer:customerRightdetail:add")
    @Log(title = "会员权益", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CustomerRightdetail customerRightdetail)
    {
        return toAjax(customerRightdetailService.insertCustomerRightdetail(customerRightdetail));
    }

    /**
     * 修改会员权益
     */
    //@PreAuthorize(hasPermi = "customer:customerRightdetail:edit")
    @Log(title = "会员权益", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerRightdetail customerRightdetail)
    {
        customerRightdetail.setRightdetailName("555");
        return toAjax(customerRightdetailService.updateCustomerRightdetail(customerRightdetail));
    }

    /**
     * 删除会员权益
     */
    @PreAuthorize(hasPermi = "customer:customerRightdetail:remove")
    @Log(title = "会员权益", businessType = BusinessType.DELETE)
	@DeleteMapping("/{icustomerRightdetailDs}")
    public AjaxResult remove(@PathVariable Long[] icustomerRightdetailDs)
    {
        return toAjax(customerRightdetailService.deleteCustomerRightdetailByIds(icustomerRightdetailDs));
    }

    /**
     * 查询会员是否有贵宾厅无限券
     * */
    @PostMapping("/infiniteVIPHall")
    public boolean infiniteVIPHall(@RequestParam("id") Long id){
        boolean flag = customerRightdetailService.infiniteVIPHall(id);
        return flag;
    }
}
